#include "pub_defs.h"

/**
 * @brief baseline
 * @param x position array
 * @param v velocity array
 * @param n number of bodies
 * @param tmax number of time periods
 * @param m mass of each body
 * @param dt time step
*/
void calc_xv_optimized(TD* x, TD* v, const int n, const int tmax, const double m, const double dt) {
    TD F;
    double par = dt/m;

    #pragma omp parallel for private(F) schedule(static)
    for (int i = 0; i < n; i++) { 
        TD xtmp = x[i];
        TD vtmp = v[i];
        for (int t = 0; t < tmax; t++) { 
            F = F_routine(i); 
            TD at = F*par;
            vtmp = vtmp + at;
            xtmp = xtmp + vtmp * dt;
        } 
        x[i] = xtmp;
        v[i] = vtmp;
    }
}